package com.zhou.JavaAndroidFirm.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.zhou.JavaAndroidFirm.R;
import com.zhou.JavaAndroidFirm.activity.PhotosDetailActivity;
import com.zhou.JavaAndroidFirm.bean.PhotoGirl;
import com.zhou.JavaAndroidFirm.utils.ViewHolderHelper;

import java.util.List;

/**
 * @author Administrator
 * @date 2018/7/18 0018
 * @des
 */
public class PhotoGirlAdapter extends CommonRecycleViewAdapter<PhotoGirl> {
    public PhotoGirlAdapter(Context context, int layoutId, List<PhotoGirl> mDatass) {
        super(context, layoutId, mDatass);
    }

    @Override
    public void convert(ViewHolderHelper helper, final PhotoGirl bean) {
        ImageView image = helper.getView(R.id.iv_photo);
        Glide.with(mContext).load(bean.getUrl())
                .apply(new RequestOptions()
                        .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
                        .placeholder(R.drawable.ic_image_loading)
                        .error(R.drawable.ic_empty_picture)
                        .centerCrop()
                        .override(1090, 1090 * 3 / 4))
                .transition(DrawableTransitionOptions.withCrossFade()) //动画渐变加载
                .into(image);
        image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhotosDetailActivity.startAction(mContext, bean.getUrl());
            }
        });
    }
}
